import {Navigate,useRoutes} from "react-router-dom"
import lazyLoad from "@/hooks/lazyLoad"
import React from "react"

const metaRoutes = import.meta.glob("./module/*.tsx",{eager:true});
const routerArray: any[]=[]
Object.keys(metaRoutes).forEach(item=>{
    Object.keys(metaRoutes[item]).forEach(key=>{
        routerArray.push(...metaRoutes[item][key])
    })
})


export const rooterRouter=[
    {
        path:'/',
        element:<Navigate to="/login"></Navigate>
    },
    {
        path:"/login",
        element:lazyLoad(React.lazy(()=>import('@/pages/login/login'))),
        meta:{
            requireAuth:false,
            title:"首页",
            key:"login"
        }
    },
    {
        path:'/home',
        element:lazyLoad(React.lazy(()=>import('@/pages/home/home')))
    }
    ,,,routerArray
]

const Router=()=>{
   return useRoutes(rooterRouter)
}
export default Router